package com.dddframework.web.auth.controller;


import com.dddframework.core.contract.R;
import com.dddframework.web.auth.annotation.Inside;
import com.dddframework.web.core.AccessToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/open")
@Inside
public class AuthController {
    /**
     * 获取AccessToken
     *
     * @param appId
     * @param appSecret
     * @param refresh
     * @return
     */
    @GetMapping("/accessToken")
    public R<AccessToken> getAccessToken(@RequestParam("appId") String appId, @RequestParam("appSecret") String appSecret, @RequestParam(value = "refresh", required = false) Integer refresh) {
        return R.ok(AccessToken.cache(appId, appSecret, refresh));
    }
}
